<template>
  <div class="home">

    <el-container>
        <!-- 侧边栏 -->
      <el-aside width="200px">
        <div class="logo">
          <!-- logo -->
        </div>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :router='true'
        >
          <el-submenu :index="i+''" v-for="(item,i) in menusList" :key="item.id">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{item.authName}}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item :index="'/home/'+item.path" v-for="item in item.children" :key="item.id">
                  <i class="el-icon-menu"></i>
              {{ item.authName }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

        <!-- 内容区域 -->
      <el-container>
          <!-- 头部 -->
        <el-header>
          <i class="el-icon-s-unfold"></i>
          <h1>后台管理系统</h1>
          <div>
            欢迎，XXX
            <span>退出</span>
          </div>
        </el-header>
        <!-- main区域 -->
        <el-main>
            <router-view></router-view>
        </el-main>

      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
        menusList:[]
    };
  },

  methods: {
      getMenus(){
          this.axios.get('menus').then(res=>{
              if(res.data.data) {
                this.menusList = res.data.data;
              }
          })
      }
  },

  created() {
      this.getMenus();
  }
};
</script>

<style lang='less' scoped>
.home {
    text-align: left;
  height: 100%;
  .el-container {
    height: 100%;
    .el-aside {
      background-color: #545c64;
      .logo {
        height: 60px;
        background: url("../assets/logo1.png");
        background-size: cover;
        background-color: #fff;
      }
      .el-menu {
          ul {
              border: none;
          }
      }
    }
    .el-header {
      background-color: #545c64;
      display: flex;
      align-items: center; // 纵轴居中
      justify-content: space-between;
      color: #fff;
      i {
        cursor: pointer;
        font-size: 35px;
      }
      span {
        cursor: pointer;
        color: rgb(188, 188, 238);
      }
    }
  }
}
</style>
